﻿namespace SVMS
{
    /// <summary>
    /// 系统配置类。
    /// </summary>
    internal static class AppConfig
    {
        /// <summary>
        /// 取得系统ID。
        /// </summary>
        public static string AppId => "SVMS.Admin";

        /// <summary>
        /// 取得系统名称。
        /// </summary>
        public static string AppName => "短视频营销系统";

        /// <summary>
        /// 添加系统配置。
        /// </summary>
        /// <param name="services">服务集合。</param>
        /// <param name="action">配置委托。</param>
        internal static void AddApplication(this IServiceCollection services, Action<CoreOption> action)
        {
            Console.WriteLine(AppName);
            // 添加前端
            var assembly = typeof(AppConfig).Assembly;
            services.AddKnown(option =>
            {
                option.Id = AppId;
                option.Name = AppName;
                option.Assembly = assembly;
            });
            services.AddKnownAdmin();
            services.AddModules();

            // 添加后端
            services.AddServices(assembly);
            services.AddTaskJobs();
            services.AddKnownCells();
            services.AddKnownAdminCore();
            services.AddKnownWeb(action);
        }

        internal static void UseApplication(this WebApplication app)
        {
            app.UseKnown();
            app.UseTaskJobs();
        }

        public static void AddSample(this IServiceCollection services)
        {
            Config.OnSetting = s =>
            {
                s.MultiTab = true;    // 是否标签页
                s.Accordion = true;   // 是否手风琴
                s.Collapsed = true;   // 是否折叠
                s.MenuTheme = "Dark"; // Light/Dark两种
            };
            services.AddKnown(info =>
            {
                // 这里是系统配置信息
            });
        }
    }
}